package com.ccx.service.impl;

import com.ccx.mapper.EbOrderMapper;
import com.ccx.model.EbOrder;
import com.ccx.model.EbOrderExample;
import com.ccx.service.EbOrderService;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EbOrderServiceImpl implements EbOrderService {

    @Autowired
    EbOrderMapper ebOrderMapper;

    /**
     * 添加
     */
    public int insertTest(EbOrder ebOrder){
        return ebOrderMapper.insertSelective(ebOrder);
    }

    /**
     * 查询
     */
    public List<EbOrder> selectSuccess(int eoId,String eoUserName,int page,int pageSize){
        PageHelper.startPage(page,pageSize);
        EbOrderExample ebOrderExample = new EbOrderExample();
        EbOrderExample.Criteria criteria = ebOrderExample.createCriteria();
        if(eoId == 0 && eoUserName != null){
            criteria.andEoUserNameEqualTo(eoUserName);
        }else if(eoId != 0 || eoUserName == null){
            criteria.andEoIdEqualTo(eoId);
        }else {
            criteria.andEoIdEqualTo(eoId).andEoUserNameEqualTo(eoUserName);
        }
        return ebOrderMapper.selectByExample(ebOrderExample);
    }

    /**
     * 修改
     */
    public int updateTest(EbOrder ebOrder){
        return ebOrderMapper.updateByPrimaryKeySelective(ebOrder);
    }

    /**
     * 删除
     */
    public int deleteTest(int eoid){
        return ebOrderMapper.deleteByPrimaryKey(eoid);
    }

    /**
     * 分页查询
     */
    public List<EbOrder> pageTest(int page,int pageSize){
        PageHelper.startPage(page,pageSize);
        return ebOrderMapper.selectByExample(null);
    }

    @Override
    public EbOrder selectByOrder(Integer eoId) {
        return ebOrderMapper.selectByPrimaryKey(eoId);
    }

    /**
     *
     */
}
